import { defineConfig, preprocessCSS } from 'vite';
import vue from '@vitejs/plugin-vue';
import { resolve } from 'path'; 
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';

const pathResolve = dir => resolve(__dirname, dir)

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    createSvgIconsPlugin({
			iconDirs: [resolve(process.cwd(), 'src/assets/svg')],
			symbolId: 'icon-[dir]-[name]',
		}),
  ],
  // 下面配置scss,在vue-cli设置，vite不需要
  pluginOptions: {
    'style-resources-loader': {
      preprocessor: 'scss',
      patterns: []
    }
  },

  // 设置 @ 指向src目录
  resolve: {
    alias: {
      '@': pathResolve('./src') 
    }
  },
  server: {
    port: 8080, // 设置服务启动端口号
    open: true, // 设置服务启动时是否自动打开浏览器
    cors: true, // 允许跨域
  }
})
